#pragma once
#include<memory>
#include<iostream>
#include "Log.hpp"
#include<string>
#include"Mutex.hpp"
#include"cond.hpp"
#include"Thread.hpp"
#include<queue>
#include<vector>
#define defualtTest test
namespace threadPoolModule
{
    using namespace LogMudule;
    using namespace ThreadModule;
    using namespace LockModule;
    using namespace condMoudle;
    const static int defaultnum = 5;
    using thread_t  = std::shared_ptr<Thread>;

    void test()
    {
        while (true)
        {
            LOG(LogLevel::DEBUG) << "这是一个测试方法";
            sleep(1);
        }
        
    }
    template<class T>
    class threadPool
    {
    private:
        int _num;
        std::queue<T> _taskq;
        
        std::vector<thread_t> _threads;
        Mutex _lock;
    public:
        threadPool(int num = defaultnum): _num(num)
        {
            for (int i = 0; i < _num; i++)
            {
                _threads.emplace_back(std::make_shared<Thread()>(defualtTest));
                LOG(LogLevel::DEBUG) << "构建线程" ;
                std::cout <<  _threads.back()->Name() << std::endl;
            }
        }
        ~threadPool();
        void start()
        {
            for (auto& tptr : _threads)
            {
                tptr->Start();
                LOG(LogLevel::INFO) << "启动线程" << _threads.back()->Name() << "...成功";
            }
        }
        void wait()
        {
            for (auto& tptr : _threads)
            {
                tptr->Join();
            }
        }
        void equeue()
        {

        }
        void stop()
        {

        }
    };

    
}